﻿using AutoMapper;
using MiniErp.Entity.DataStreams.BOs;
using MiniErp.Entity.DataStreams.DOs.AssetManagement;
using MiniErp.Entity.DataStreams.DTOs.AssetManagement;
using MiniErp.Repository.MysqlRepository.IRepository.AssetManagement;
using MiniErp.Repository.UnitOfWorkCore;
using MiniErp.Service.BusinessService.IService.AssetManagement;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MiniErp.Service.BusinessService.Service.AssetManagement
{
    public class AssetRecordService : BaseService, IAssetRecordService
    {
        private readonly IAssetModificationRecordRepository _amrr;
        public AssetRecordService(IAssetModificationRecordRepository amrr, IMysqlUnitOfWork mysqlUnitOfWork, IMapper mapper) : base(mysqlUnitOfWork, mapper)
        {
            _amrr = amrr;
        }
        public async Task<List<AssetModificationRecordDTO>> GetAllRecordAsync(DateTime startTime, DateTime endTime, int Page, int num)
        {
            var result = await _amrr.GetAllRecordAsync(startTime, endTime, Page, num);
            return result == null
                ? throw new ExceptionBO("未查询到数据")
                : _mapper.Map<List<AssetModificationRecordDTO>>(result);

        }

        public async Task<List<AssetModificationRecordDTO>> GetFuzzyRecordAsync(string value, DateTime startTime, DateTime endTime, int Page, int num)
        {
            var result = await _amrr.GetFuzzyRecordAsync(value, startTime, endTime, Page, num);
            return result == null
                ? throw new ExceptionBO("未查询到数据")
                 : _mapper.Map<List<AssetModificationRecordDTO>>(result);
        }
    }
}
